﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PopcornBTMonitor.Command;
using System.IO;

namespace PopcornBTMonitor.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            if (CheckArgs(args))
            {
                TorrentUploader uploader = new TorrentUploader();

                if (uploader.UploadTorrent(args[0]))
                {
                    System.Console.WriteLine("Torrent successfully uploaded");
                }
                else
                {
                    System.Console.WriteLine("Failed to upload torrent");
                }
            }
        }

        static bool CheckArgs(string[] args)
        {
            if (args.Length != 1)
            {
                Usage();
                return false;
            }

            if (!File.Exists(args[0]))
            {
                Usage();
                return false;
            }

            return true;
        }

        static void Usage()
        {
            System.Console.WriteLine("Main: Invalid usage: PopcornBTMonitor.Console [Torrent File]");
        }
    }
}
